import { ApiProperty, PickType } from '@nestjs/swagger';
import { IsInt, IsOptional, IsString } from 'class-validator';
import { BannerEntity } from './banner.entity';
import { CommonStatus } from '~/common/entity/common.entity';

export class CreateBannerDto extends PickType(BannerEntity, [
	'imageUrl',
	'title',
	'linkUrl',
	'isActive',
] as const) {
	@ApiProperty({ description: '图片地址', default: '必填，http|https://...' })
	@IsString()
	imageUrl: string;

	@ApiProperty({ description: '图片标题', default: '' })
	@IsOptional()
	@IsString()
	title: string;

	@ApiProperty({ description: '跳转链接', default: '' })
	@IsOptional()
	@IsString()
	linkUrl: string;

	@ApiProperty({ description: '是否启用', default: 1 })
	@IsOptional()
	@IsInt()
	isActive: CommonStatus;

	@ApiProperty({ description: '租户ID', default: null, required: true })
	@IsInt({ message: '租户ID必须是数字' })
	@IsOptional()
	tenantId: number;
}
